<template>
    <div>
      <van-coupon-cell
        :coupons="coupons"
        :chosen-coupon="chosenCoupon"
        @click="showList = true"
      />
      <van-popup v-model="showList" position="bottom">
        <van-coupon-list
          :coupons="coupons"
          :show-exchange-bar="showExchangeBar"
          :chosen-coupon="chosenCoupon"
          :disabled-coupons="disabledCoupons"
          @change="onChange"
          @exchange="onExchange"
        />
      </van-popup>

    </div>
</template>

<script>

    export default {
        name: "coupon",
      props:["coupon"],
      data() {
        return {
          /*ticketTitle:coupon.ticket_title,*/
          showList:false,
          chosenCoupon: -1,
          showExchangeBar:false,
          coupons: [],
          disabledCoupons: []
        }
      },

      methods: {
        onChange(index) {
          this.showList = false;
          this.chosenCoupon = index;
        },
        onExchange(code) {
          this.coupons.push(coupon);
        },

      },
      mounted(){
        //coupons.name=this.coupon.ticket_title;
        let coupons = {
          available: 1,
          discount: 8.5,
          denominations: this.coupon.price*100,
          originCondition: 0,
          reason: '',
          value: 150,
          name:this.coupon.ticket_title ,//coupon.ticket_title
          startAt: 1489104000,
          endAt: this.coupon.end_time
        };
        const discoupon = {
          available: 1,
          discount: 0,
          denominations: 150,
          originCondition: 0,
          reason: '',
          value: 150,
          name: "不可用优惠券",
          startAt: 1489104000,
          endAt: 1514592000
        };
        this.coupons.push(coupons);
        this.disabledCoupons.push(discoupon);
      }

    }
</script>

<style scoped>

</style>
